home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / IO / BufferedOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  886 b   |  41 lines

  1. package java.io;
  2.  
  3. public class BufferedOutputStream extends FilterOutputStream {
  4.    protected byte[] buf;
  5.    protected int count;
  6.  
  7.    public BufferedOutputStream(OutputStream var1) {
  8.       this(var1, 512);
  9.    }
  10.  
  11.    public BufferedOutputStream(OutputStream var1, int var2) {
  12.       super(var1);
  13.       this.buf = new byte[var2];
  14.    }
  15.  
  16.    public synchronized void write(int var1) throws IOException {
  17.       if (this.count == this.buf.length) {
  18.          this.flush();
  19.       }
  20.  
  21.       this.buf[this.count++] = (byte)var1;
  22.    }
  23.  
  24.    public synchronized void write(byte[] var1, int var2, int var3) throws IOException {
  25.       int var4 = this.buf.length - this.count;
  26.       if (var3 <= var4) {
  27.          System.arraycopy(var1, var2, this.buf, this.count, var3);
  28.          this.count += var3;
  29.       } else {
  30.          this.flush();
  31.          super.out.write(var1, var2, var3);
  32.       }
  33.    }
  34.  
  35.    public synchronized void flush() throws IOException {
  36.       super.out.write(this.buf, 0, this.count);
  37.       super.out.flush();
  38.       this.count = 0;
  39.    }
  40. }
  41.